/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package filmlibrary.web;

import filmlibrary.orm.ORMHelper;
import filmlibrary.orm.classes.Films;
import java.util.List;
import java.util.logging.Logger;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.RequestScoped;


/**
 *
 * @author karol
 */
@ManagedBean
@RequestScoped
public class FilmsBean implements java.io.Serializable{
    private static final Logger logger = Logger.getLogger("filmlibrary.web.FilmsBean");
    private ORMHelper orm = new ORMHelper();
    private List <Films> myfilms=null;
    /** Creates a new instance of FilmsBean */
    public FilmsBean() {
        logger.info("konstruktor FilmsBean");
        myfilms = getMyFilmsFromDB();
    }
    public String delete(int id){        
        orm.deleteFilm(id);
        
        return "myFilms.xhtml?faces-redirect=true";
    }
     private List<Films> getMyFilmsFromDB(){

        List<Films> lf = orm.getUserFilms(new SessionBean().getLogin());
        return lf;
    }

    public List<Films> getMyfilms() {
        return myfilms;
    }
    public String edit(){
        return "edit.xhtml?faces-redirect=true";
    }
     

}